import Vue from 'vue'
import VueRouter from 'vue-router'

// 一级路由
import layout from '../views/layout.vue'
import login from '../views/login.vue'
import register from '../views/register.vue'
import detail from '../views/detail.vue'

// 二级路由
import article from '../views/article.vue'
import collect from '../views/collect.vue'
import like from '../views/like.vue'
import user from '../views/user.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: layout,
    // 重定向
    redirect: '/article',
    children: [
      {
        path: 'article',
        component: article
      },
      {
        path: 'collect',
        component: collect
      },
      {
        path: 'like',
        component: like
      },
      {
        path: 'user',
        component: user
      }
    ]
  },
  {
    path: '/login',
    component: login
  },
  {
    path: '/register',
    component: register
  },
  {
    path: '/detail',
    component: detail
  }
]

const router = new VueRouter({
  routes
})

export default router
